﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace sy3_3
{
    internal class Program
    {
      
class Rect
    {
        protected double length, width;
        public Rect() { length = width = 0; }
        public Rect(double len, double wid) { length = len; width = wid; }
        public virtual double GetArea() { return length * width; }
        public double GetPerimeter() { return 2 * (length + width); }
    }

    class Cubold : Rect
    {
        protected double height;
        public Cubold(double len, double wid, double hei) : base(len, wid) { height = hei; }
        public override double GetArea() { return 2 * (length * width + length * height + width * height); }
        public double GetVolume() { return length * width * height; }
    }

    
        static void Main()
        {
            Console.Write("请输入矩形长：");
            double len = Convert.ToDouble(Console.ReadLine());
            Console.Write("请输入矩形宽：");
            double wid = Convert.ToDouble(Console.ReadLine());
            Rect rect = new Rect(len, wid);
            Console.WriteLine($"解：矩形面积为 {rect.GetArea()} ，周长为 {rect.GetPerimeter()} 。");

            Console.WriteLine("\n====在此基础上构造矩体====");
            Console.Write("请输入矩体高：");
            double hei = Convert.ToDouble(Console.ReadLine());
            Cubold cubold = new Cubold(len, wid, hei);
            Console.WriteLine($"解：矩体表面积为 {cubold.GetArea()} ，体积为 {cubold.GetVolume()} 。");

            Console.WriteLine("\n按任意键结束程序：");
            Console.ReadKey();
        }
}
       
    }

